package 数组;

public class 除自身以外数组的乘积 {

    public int[] productExceptSelf(int[] nums) {
        int[] result = new int[nums.length];
        for (int i = 0; i < result.length; i++) {
            int resultNum = 1;
            for (int j = 0; j < nums.length; j++) {
                if (j != i) {
                    resultNum = resultNum * nums[j];
                }
            }
            result[i] = resultNum;
        }
        return result;
    }
}
